<?php defined('_JEXEC') or die('Restricted access'); ?>

<h1 class="componentheading"><?php echo JText::_("List of Religious") ?> </h1>

<form action="" method="post" name="filterForm">
<table>
<tr>
	<td align="left" width="100%">
		<?php echo JText::_( 'Filter' ); ?>:
		<input type="text" name="profilesearch" id="profilesearch" value="<?php echo htmlspecialchars($this->lists['profilesearch']);?>"/>
		<button onclick="this.form.submit();"><?php echo JText::_( 'Go' ); ?></button>
		<button onclick="document.getElementById('profilesearch').value='';this.form.getElementById('cid').value='';this.form.getElementById('pid_cid').value='';this.form.submit();"><?php echo JText::_( 'Filter Reset' ); ?></button>
	</td>
</tr>
<tr>
	<td nowrap="nowrap"><?php echo JText::_("House:") ?> 
			<select name='pid_cid' id='pid_cid' class='inputbox' size='1' onchange="document.filterForm.submit();">
			<option value=''><?php echo JText::_( 'All' ) ?></option>
			<?php $last_p_id = 0 ?>
			<?php foreach($this->lists['houses'] as $house): ?>
			<?php if($last_p_id != $house->p_id): ?>
			<option value="<?php echo $house->p_id ?>" <?php if($house->p_id == $this->pid_cid) echo " selected='selected' " ?>><?php echo $house->p_name ?></option>
			<?php endif; ?>
			<?php $last_p_id = $house->p_id ?>
			<option value='<?php echo $house->p_id . ":" . $house->c_id ?>' <?php if(($house->p_id . ":" . $house->c_id) == $this->pid_cid) echo " selected='selected' " ?> >|__<?php echo $house->c_name?></option>
			<?php endforeach; ?>
			</select>
	</td>
</tr>
</table>
<input type="hidden" name="option" value="com_congregation" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="c_id" value="<?php echo $this->c_id ?>"/>
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="controller" value="profile" />

</form>
<?php if($this->items): ?>

	<table class="list" width="100%">
	<thead>
		<tr>
			<th width="30%">
				<?php echo JText::_( 'Username' ); ?>
			</th>
			<th width="30%">
				<?php echo JText::_( 'Name' ); ?>
			</th>
			<th>
				<?php echo JText::_( 'Email' ); ?>
			</th>
		</tr>
	</thead>
	<?php
	$k = 0;
	
	for ($i=0, $n=count( $this->items ); $i < $n; $i++)	{
		$row = &$this->items[$i];
		$link 		= JRoute::_( 'index.php?option=com_congregation&controller=profile&task=show&username='. $row->username );
		?>
		<tr class="<?php echo "row$k"; ?>">
			<td>
				<a href="<?php echo $link ?>">
				<?php echo $row->username ; ?>
				</a>
			</td>
			<td>
				<?php echo $row->name ; ?>
			</td>
			<td>
				<?php echo $row->email ; ?>
			</td>
		</tr>
		<?php
		$k = 1 - $k;
	}
	?>
	</table>

<?php echo $this->pagination->getListFooter(); ?>
	
<?php else: ?>
<p><?php echo JText::_( 'No user found' ) ?> </p>
<?php endif; ?>

